home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # fxm - a command line interface to Faximum
- #
- # Client/Server Release 1.0 - @(#)fxm 1.10 94/11/02
- #
- # ****************************************************************************
- # * *
- # * *
- # * Copyright Faximum Software Inc. 1993-1994 *
- # * *
- # * All Rights Reserved. An unpublished and CONFIDENTIAL work. *
- # * Reproduction, adaptation, or translation without prior written *
- # * permission is prohibited except as allowed under the copyright laws. *
- # * *
- # * *
- # * RESTRICTED RIGHTS LEGEND *
- # * *
- # * Use, duplication, or disclosure by the U.S. Government is subject to *
- # * restrictions as set forth in subparagraph (c) (1) (ii) of the Rights *
- # * in Technical Data and Computer Software clause in DFARS 252.227-7013. *
- # * Rights for non-DOD U.S. Government Departments and Agencies are as set *
- # * forth in FAR 52.227-19(c) (1,2). *
- # * *
- # * Faximum Software Inc. *
- # * 1497 Marine Drive, Suite 300 *
- # * West Vancouver, BC, Canada, V7T 1B8 *
- # * *
- # ****************************************************************************
- #
- trap "rm -rf /tmp/fxm.$$*" 1 2 15
- FAXHOME=${FAXHOME:-/opt/FAXclient}
- PATH=$FAXHOME/bin:/bin:/usr/bin
- itemno=1
- export FAXHOME PATH
-
- #
- # The following ought to point to the name of the system which is
- # running the fax server. On SunFax installations, this is the localhost,
- # on fully networked client/server installations this is usually the
- # alias faxhost although any valid hostname may be used.
-
- FAXHOST=localhost
- export FAXHOST
-
- #
- # Set default values for some parameters:
- #
- # Note that if no cover sheet related parameters are specified (such as the
- # to and from names), then the default style will be FAXNCSTYLE. If such
- # parameters *are* provided, then the default style will be FAXCSTYLE.
- #
-
- FAXNCSTYLE=${FAXSTYLE:-"No Cover Sheet (Fine)"}
- FAXCSTYLE=${FAXSTYLE:-"Default"}
- FAXACCOUNT=${FAXACCOUNT:-"Default"}
- FAXCLASS=${FAXCLASS:-"Default"}
- FAXFROM=${FAXFROM:-"`logname`@`uname -n`"}
-
- FILES=no
-
- MESSAGE=""
- MESSAGEFILE=""
- FAXSUBJECT=""
- FROMNAME=""
- FROMTITLE=""
- FROMDEPT=""
- TONAME=""
- TOTITLE=""
- TODEPT=""
- COMPANY=""
-
- FSTYLE=""
- COVERSHEET=no
- PHONE=""
-
- MYNAME=$0
- TF=/tmp/fxm.$$
-
- if [ $# -eq 0 ]
- then
- more << EOF
- Usage: $0 phone-number [options] files...
-
- Options:
- -a account name (by default: '$FAXACCOUNT')
- -c class (by default: $FAXCLASS)
- -f information identifying the sender. May be repeated up to 3
- times. For example:
- -f "from-name" -f "from-title" -f "from-dept"
- -m msgtext the text of a message to go on the cover sheet
- -M msgfile cover sheet message file
- -o information identifying the recipient (organisation or company).
- -r subject (i.e re:)
- -s style (by default: '$FAXCSTYLE' if any of
- -f, -r, -t, -m, or -M are used, otherwise '$FAXNCSTYLE')
- -t information identifying the recipient (person). May be repeated up to 3
- times. For example:
- -t "to-name" -t "to-title" -t "to-department"
-
-
- phone-number the fax number. If intelligent dialling is enabled and this
- number does not have four parts (country code (USA=1), area
- code, exchange, and number), then the country code and (if
- necessary) the area code for your site will be added.
- Must be enclosed in quotation marks if it contains a space.
-
- files the list of attachments. If a specific style is required for
- an overlay (for example, to arrange for an overlay) then use
- the -S flag. Each file will be analysed to determine its file
- type. To force a specific file type use the -T option.
- Note that -S and -T options apply to all remaining attachments
- until superseded.
-
- If standard input is intended, specify the file name -
-
- If no file names are specified, then standard input is assumed.
-
- -S attachment-style
- (i.e. name in the style database)
- -T attachment-type
- (one of: ascii, ps, pcl, tiff)
-
- Examples:
- $0 555-1212 technote.tif
-
- $0 -t "John Doe" -o "ACME Cement" -f "Jane Smith" -f "Engineering" "1 604 926 8182" file
-
- Defaults:
- You may specify default values for the style, account, class, type, and from
- options by setting the following environment variables: FAXSTYLE,
- FAXACCOUNT, FAXCLASS, and FAXFROM
- EOF
- exit
- fi
-
- > ${TF}.c
-
- while [ "$1" != "" ]
- do
- case "$1" in
- -a )
- FAXACCOUNT="$2"
- shift
- ;;
-
- -c )
- FAXCLASS="$2"
- shift
- ;;
-
- -f )
- COVERSHEET=yes
- if [ "$FROMNAME" ]
- then
- if [ "$FROMTITLE" ]
- then
- FROMDEPT="$2"
- else
- FROMTITLE="$2"
- fi
- else
- FROMNAME="$2"
- fi
- shift
- ;;
-
- -M )
- COVERSHEET=yes
- if [ -r "$2" ]
- then
- MESSAGEFILE="$2"
- else
- echo "$MYNAME: Error - cannot access file ($2)"
- exit 1
- fi
- shift
- ;;
-
- -m )
- COVERSHEET=yes
- MESSAGE="$2"
- shift
- ;;
-
- -o )
- COVERSHEET=yes
- TOCOMPANY="$2"
- shift
- ;;
-
- -r )
- COVERSHEET=yes
- FAXSUBJECT="$2"
- shift
- ;;
-
- -s )
- FSTYLE="$2"
- shift
- ;;
-
- -t )
- COVERSHEET=yes
- if [ "$TONAME" ]
- then
- if [ "$TOTITLE" ]
- then
- TODEPT="$2"
- else
- TOTITLE="$2"
- fi
- else
- TONAME="$2"
- fi
- shift
- ;;
-
- -S )
- if [ ! "$PHONE" ]
- then
- echo "$MYNAME: Error - no phone number specified"
- exit 1
- fi
- STYLE=$2
- shift
- ;;
-
- -T )
- if [ "$PHONE" = "" ]
- then
- echo "$MYNAME: Error - no phone number specified"
- rm -rf ${TF}*
- exit 1
- fi
- case $2 in
- a | ascii | A | ASCII )
- TYPE=ASCII
- ;;
- tif | tiff | TIF | TIFF )
- TYPE=TIFF
- ;;
- ps | PS | PostScript | postscript | POSTSCRIPT )
- TYPE=PostScript
- ;;
- pcl | PCL | pcl-? | PCL-? )
- TYPE=PCL
- ;;
- * )
- echo "$MYNAME: Error - bad file type ($2)"
- rm -rf ${TF}*
- exit 1
- ;;
- esac
- shift
- ;;
-
- * )
- if [ "$PHONE" = "" ]
- then
- PHONE="$1"
- elif [ "$1" = "-" ]
- then
- # attachment is standard input
- FILES=yes
- cat > ${TF}.${itemno}
- echo "file_name${itemno} = /tmp/fxm.$$.${itemno}" >> ${TF}.c
- if [ "$STYLE" ]
- then
- echo "file_style${itemno} = ${STYLE}" >> ${TF}.c
- fi
- if [ "$TYPE" ]
- then
- echo "file_type${itemno} = ${TYPE}" >> ${TF}.c
- fi
- echo "file_delete${itemno} = yes" >> ${TF}.c
- itemno=`expr $itemno + 1`
- elif [ -r "$1" ]
- then
- # we have an attachment
- #
- FILES=yes
- echo "file_name${itemno} = $1" >> ${TF}.c
- if [ "$STYLE" ]
- then
- echo "file_style${itemno} = ${STYLE}" >> ${TF}.c
- fi
- if [ "$TYPE" ]
- then
- echo "file_type${itemno} = ${TYPE}" >> ${TF}.c
- fi
- itemno=`expr $itemno + 1`
- else
- echo "$MYNAME: Error - cannot access file ($1)"
- rm -rf ${TF}*
- exit 1
- fi
- ;;
- esac
- shift
- done
-
- if [ $FILES = no ]
- then
- # file must come from standard input
- cat > ${TF}.${itemno}
- echo "file_name${itemno} = /tmp/fxm.$$.${itemno}" >> ${TF}.c
- if [ "$STYLE" ]
- then
- echo "file_style${itemno} = ${STYLE}" >> ${TF}.c
- fi
- if [ "$TYPE" ]
- then
- echo "file_type${itemno} = ${TYPE}" >> ${TF}.c
- fi
- echo "file_delete${itemno} = yes" >> ${TF}.c
- itemno=`expr $itemno + 1`
- fi
-
- if [ "$FSTYLE" ]
- then
- FAXSTYLE="$FSTYLE"
- else
- if [ $COVERSHEET = "yes" ]
- then
- FAXSTYLE="$FAXCSTYLE"
- else
- FAXSTYLE="$FAXNCSTYLE"
- fi
- fi
-
- if [ ! "$PHONE" ]
- then
- echo "$MYNAME: Error - Missing phone number."
- rm -rf ${TF}*
- exit 1
- fi
-
- #
- # Put the rest of the parameters into the command file
- #
-
- cat >> ${TF}.c <<- EOF
- dest_name1 = "$TONAME"
- dest_title1 = "$TOTITLE"
- dest_dept1 = "$TODEPT"
- dest_company1 = "$TOCOMPANY"
- dest_fax1 = "$PHONE"
- class = "$FAXCLASS"
- style = "$FAXSTYLE"
- account = "$FAXACCOUNT"
- from_name = "$FROMNAME"
- from_title = "$FROMTITLE"
- from_dept = "$FROMDEPT"
- subject = "$FAXSUBJECT"
- message = "$MESSAGE"
- messagefile = "$MESSAGEFILE"
- EOF
-
- #
- # Send the command file off to submitfax...
- #
- ${FAXHOME}/lib/submitfax ${TF}.c
- rm -f ${TF}.c
-